package com.test.controller;

import com.test.entities.HandDepartments;
import com.test.service.DeptService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dell
 */
@RestController
public class DeptController {

   @Autowired
   private DeptService deptService;

    @PostMapping("/dept/add")
   public HandDepartments add(@RequestBody HandDepartments departments){
        return deptService.addDept(departments);
   }

    @GetMapping("/dept/list")
    public List<HandDepartments> findAll() {
       return deptService.findAll();
    }

    @GetMapping("/dept/get/{id}")
    public HandDepartments findById(@PathVariable("id") Long departmentId){
       return deptService.findById(departmentId);
    }

    @DeleteMapping("/dept/del/{id}")
    public void delete(@PathVariable Long id) {
        deptService.delete(id);
    }

}
